#ifndef __IOBOT_H
#define __IOBOT_H

#define bot_TOP				205
#define bot_BOTTOM			205
#define bot_LEFT				186
#define bot_RIGHT				186
#define bot_TOP_LEFT			201
#define bot_TOP_RIGHT		187
#define bot_BOTTOM_LEFT		200
#define bot_BOTTOM_RIGHT	188
#define bot_LEADIN			181
#define bot_LEADOUT			198

typedef struct
{
	s8int *name;

	u32int x;
	u32int y;
	u32int width;
	u32int height;

	u32int textwidth;
	u32int textheight;
	u32int csr_x;
	u32int csr_y;
	u32int scroll;

	u8int dirty;
	u32int dirty_x;
	u32int dirty_y;
	u32int dirty_width;
	u32int dirty_height;

	u8int stdout[12288];//just over 3 pages worth of 80x50 text, 12 kilobytes
	u32int stdin_write_pos;
	u32int stdin_read_pos;
	u8int stdin[1024];//a 1 kilobyte input buffer

	u32int scrl;
	u32int num;
	u32int caps;
	u32int capslock;
	u32int ctrl;
	u32int alt;
	
}iobot_t;

//reads all input from the keyboard,s32interprets the scan codes (letters, escape sequences etc.),
//and writes the results to stdin.
void iobot_update_input(iobot_t *bot);
void iobot_process_scancode(iobot_t *bot, u8int scncode);
void iobot_clear_input(iobot_t *bot);

//writes the contents of stdout to the screen,s32interpreting color escape sequences etc.
void iobot_update_output(iobot_t *bot);
void iobot_clear_output(iobot_t *bot);

//returns and flushes the next s8intacter from stdin. Returns zero when there are no more s8intacters.
u8int iobot_get_s8int(iobot_t *bot);

//writes to stdout in various formats
void iobot_put_s8int(iobot_t *bot, u8int c);
void iobot_put_string(iobot_t *bot, s8int *str);
void iobot_put_number(iobot_t *bot, u32int num);
void iobot_put_hex(iobot_t *bot, u32int num);

void draw_iobots();
void dirty_all_iobots();
void add_iobot(iobot_t *bot);
void remove_iobot(iobot_t *bot);
//void cycle_iobots(iobot_t *currentbot);

#endif
